import 'package:api/pages/apis/scaffold/email_item.page.dart';
import 'package:api/pages/apis/scaffold/home_item_page.dart';
import 'package:api/pages/apis/scaffold/people_item_page.dart';
import 'package:flutter/material.dart';

class ScaffoldHomePage extends StatefulWidget {
  @override
  _ScaffoldHomePageState createState() => _ScaffoldHomePageState();
}

class _ScaffoldHomePageState extends State<ScaffoldHomePage> {
  num index = 0;
  List<Widget> pageWidgetList = [
    HomeItemPage(),
    EmailItemPage(),
    PeopleItemPage()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // 页面标题
      appBar: AppBar(
        title: Text("这里是首页"),
      ),
      // 打开侧边栏
      body: pageWidgetList[index],

      // Builder(
      //   builder: (BuildContext context) {
      //     return Center(
      //         child: Column(
      //       children: <Widget>[
      //         FlatButton(
      //             onPressed: () {
      //               Scaffold.of(context).openEndDrawer();
      //             },
      //             child: Text("打开左滑侧边栏"))
      //       ],
      //     ));
      //   },
      // ),
      // 定义的悬浮按钮
      floatingActionButton: FloatingActionButton(
        child: Text('++'),
        onPressed: () {
          print('点击了 FloatingActionButton');
        },
        // 长按提示
        tooltip: "点击了 tooltips",
        // 设置悬浮按钮的背景
        backgroundColor: Colors.red,
        // 获取焦点时显示的颜色
        focusColor: Colors.green,
        // 鼠标悬浮在按钮上使 显示的颜色
        hoverColor: Colors.yellow,
        // 水波纹颜色
        splashColor: Colors.deepOrange,
        // 前景色 主要影响里面的文字
        foregroundColor: Colors.black,
        // 未点击时阴影高度
        elevation: 0,
        // 点击时阴影高度
        highlightElevation: 20.0,
      ),
      // .endFloat 默认使用 浮动右下角
      // .endDocked 右下角不浮动
      // .endTop 右上角
      // .startTop左上角
      // .centerFloat 底部中间浮动
      // .centerDocked 底部中间不浮动
      floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
      // 浮动按钮下面的标签 widget
      persistentFooterButtons: <Widget>[
        Text('sxd', style: TextStyle(color: Colors.blue)),
        Text('ss'),
        Text('ss'),
        Text('ss'),
        Text('ss'),
        Text('ss'),
      ],
      // 左侧啦
      drawer: Container(color: Colors.grey, width: 120),

      // 右侧啦
      endDrawer: Container(color: Colors.yellow, width: 200),
      bottomNavigationBar: new BottomNavigationBar(
          onTap: (value) {
            this.setState(() {
              index = value;
            });
          },
          currentIndex: index,
          items: <BottomNavigationBarItem>[
            BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
            BottomNavigationBarItem(icon: Icon(Icons.email), label: "邮件"),
            BottomNavigationBarItem(icon: Icon(Icons.people), label: "我的"),
          ]),
    );
  }
}
